﻿using System.Collections;
using FlowCanvas;
using FlowCanvas.Nodes;
using NodeCanvas.Framework;
using ParadoxNotion.Design;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    [Category("Ggame")]
    public class BeginMapExplore : LatentActionNodeBase
    {
        public override bool allowRoutineQueueing { get { return false; } }

        private const string EXPLORE_PANEL_NAME = "LibertyMenuUI";
        
        public IEnumerator Invoke(int exploreId)
        {
            BlueprintUtils.OpenCloseUI(true, EXPLORE_PANEL_NAME, exploreId.ToString(),"1");
            yield return new UnityEngine.WaitUntil(() => BlueprintUtils.UIIsShowing(EXPLORE_PANEL_NAME));
        }
        
        protected override void OnRegisterDerivedPorts(FlowNode node) {
            var p1 = node.AddValueInput<int>(parameters[0].Name);
            node.AddFlowInput("In", (f) => { Begin(Invoke(p1.value), f); });
        }
        
    }
}